<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>differenceBy</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const differenceBy = (a, b, handler) => {
            const s = new Set(b.map(handler));
            return a.map(handler).filter(x => !s.has(x));
        };
        console.log(
            differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor), // [1]
            differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], v => v.x) // [2]
        );
    </script>
</body>

</html>